package com.yjhb.android.sbz.adapter;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.FlushRecord;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;
import com.jojo.android.zxlib.tool.ZxTimeTool;

/**
 * 创建者 zx
 * 创建时间 2020/12/7 15:16
 */
public class RefreshRecordAdapter extends BaseRecyclerAdapter<RefreshRecordAdapter.RefreshRecordHolder, FlushRecord> {
    private final String TAG = "RefreshRecordAdapter";

    public RefreshRecordAdapter(Context context) {
        super(context);
    }

    @Override
    protected RefreshRecordHolder getHolder(View v) {
        return new RefreshRecordHolder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_refresh_record;
    }

    @Override
    public void onBindViewHolder(@NonNull RefreshRecordHolder refreshRecordHolder, int i) {
        if (entity.getType() == 1) {
            refreshRecordHolder.count_tv.setText("+" + entity.getCount() + "次");
            refreshRecordHolder.count_tv.setTextColor(context.getResources().getColor(R.color.red_3b));
        } else if (entity.getType() == 2) {
            refreshRecordHolder.count_tv.setText("-" + entity.getCount() + "次");
            refreshRecordHolder.count_tv.setTextColor(context.getResources().getColor(R.color.black));
        }
        refreshRecordHolder.remark_tv.setText(entity.getRemark());
        refreshRecordHolder.date_tv.setText(ZxTimeTool.getDate(entity.getCreateTime().getTime(), "MM月dd日 HH:mm"));
    }


    class RefreshRecordHolder extends RecyclerView.ViewHolder {
        TextView count_tv;
        TextView date_tv;
        TextView remark_tv;

        public RefreshRecordHolder(@NonNull View itemView) {
            super(itemView);
            count_tv = itemView.findViewById(R.id.count_tv);
            date_tv = itemView.findViewById(R.id.date_tv);
            remark_tv = itemView.findViewById(R.id.remark_tv);
        }
    }

}
